home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / new_file / mintprgs / mint112s / mint112s.lzh / file.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-14  |  21.8 KB  |  658 lines

  1. /*
  2. Copyright 1991,1992 Eric R. Smith.
  3. Copyright 1992,1993,1994 Atari Corporation.
  4. All rights reserved.
  5. */
  6.  
  7. #ifndef _filesys_h
  8. #define _filesys_h
  9.  
  10. struct filesys;        /* forward declaration */
  11. struct devdrv;        /* ditto */
  12. struct timeout;        /* and ditto */
  13.  
  14. typedef struct f_cookie {
  15.     struct filesys *fs;    /* filesystem that knows about this cookie */
  16.     ushort    dev;        /* device info (e.g. Rwabs device number) */
  17.     ushort    aux;        /* extra data that the file system may want */
  18.     long    index;        /* this+dev uniquely identifies a file */
  19. } fcookie;
  20.  
  21. #define TOS_NAMELEN 13
  22.  
  23. typedef struct dtabuf {
  24.     short    index;        /* index into arrays in the PROC struct */
  25.     long    magic;
  26. #define SVALID    0x1234fedcL    /* magic for a valid search */
  27. #define EVALID    0x5678ba90L    /* magic for an exhausted search */
  28.  
  29.     char    dta_pat[TOS_NAMELEN+1];    /* pointer to pattern, if necessary */
  30.     char    dta_sattrib;    /* attributes being searched for */
  31. /* this stuff is returned to the user */
  32.     char    dta_attrib;
  33.     short    dta_time;
  34.     short    dta_date;
  35.     long    dta_size;
  36.     char    dta_name[TOS_NAMELEN+1];
  37. } DTABUF;
  38.  
  39. /* structure for opendir/readdir/closedir */
  40. typedef struct dirstruct {
  41.     fcookie fc;        /* cookie for this directory */
  42.     ushort    index;        /* index of the current entry */
  43.     ushort    flags;        /* flags (e.g. tos or not) */
  44. #define TOS_SEARCH    0x01
  45.     char    fsstuff[60];    /* anything else the file system wants */
  46.                 /* NOTE: this must be at least 45 bytes */
  47.     struct dirstruct *next;    /* linked together so we can close them
  48.                    on process termination */
  49. } DIR;
  50.  
  51. /* structure for getxattr */
  52. typedef struct xattr {
  53.     ushort    mode;
  54. /* file types */
  55. #define S_IFMT    0170000        /* mask to select file type */
  56. #define S_IFCHR    0020000        /* BIOS special file */
  57. #define S_IFDIR    0040000        /* directory file */
  58. #define S_IFREG 0100000        /* regular file */
  59. #define S_IFIFO    0120000        /* FIFO */
  60. #define S_IFMEM    0140000        /* memory region or process */
  61. #define S_IFLNK    0160000        /* symbolic link */
  62.  
  63. /* special bits: setuid, setgid, sticky bit */
  64. #define S_ISUID    04000
  65. #define S_ISGID 02000
  66. #define S_ISVTX    01000
  67.  
  68. /* file access modes for user, group, and other*/
  69. #define S_IRUSR    0400
  70. #define S_IWUSR 0200
  71. #define S_IXUSR 0100
  72. #define S_IRGRP 0040
  73. #define S_IWGRP    0020
  74. #define S_IXGRP    0010
  75. #define S_IROTH    0004
  76. #define S_IWOTH    0002
  77. #define S_IXOTH    0001
  78. #define DEFAULT_DIRMODE (0777)
  79. #define DEFAULT_MODE    (0666)
  80.     long    index;
  81.     ushort    dev;
  82.     ushort    rdev;        /* "real" device */
  83.     ushort    nlink;
  84.     ushort    uid;
  85.     ushort    gid;
  86.     long    size;
  87.     long    blksize;
  88.     long    nblocks;
  89.     short    mtime, mdate;
  90.     short    atime, adate;
  91.     short    ctime, cdate;
  92.     short    attr;
  93. /* defines for TOS attribute bytes */
  94. #ifndef FA_RDONLY
  95. #define           FA_RDONLY           0x01
  96. #define           FA_HIDDEN           0x02
  97. #define           FA_SYSTEM           0x04
  98. #define           FA_LABEL               0x08
  99. #define           FA_DIR               0x10
  100. #define           FA_CHANGED           0x20
  101. #endif
  102.     short    reserved2;
  103.     long    reserved3[2];
  104. } XATTR;
  105.  
  106. typedef struct fileptr {
  107.     short    links;        /* number of copies of this descriptor */
  108.     ushort    flags;        /* file open mode and other file flags */
  109.     long    pos;        /* position in file */
  110.     long    devinfo;    /* device driver specific info */
  111.     fcookie    fc;        /* file system cookie for this file */
  112.     struct devdrv *dev; /* device driver that knows how to deal with this */
  113.     struct fileptr *next; /* link to next fileptr for this file */
  114. } FILEPTR;
  115.  
  116. struct flock {
  117.     short l_type;            /* type of lock */
  118. #define F_RDLCK        0
  119. #define F_WRLCK        1
  120. #define F_UNLCK        3
  121.     short l_whence;            /* SEEK_SET, SEEK_CUR, SEEK_END */
  122.     long l_start;            /* start of locked region */
  123.     long l_len;            /* length of locked region */
  124.     short l_pid;            /* pid of locking process
  125.                         (F_GETLK only) */
  126. };
  127.  
  128. /* structure for internal kernel locks */
  129. typedef struct ilock {
  130.     struct flock l;        /* the actual lock */
  131.     struct ilock *next;    /* next lock in the list */
  132.     long    reserved[4];    /* reserved for future expansion */
  133. } LOCK;
  134.  
  135. typedef struct devdrv {
  136.     long ARGS_ON_STACK (*open)    P_((FILEPTR *f));
  137.     long ARGS_ON_STACK (*write)    P_((FILEPTR *f, const char *buf, long bytes));
  138.     long ARGS_ON_STACK (*read)    P_((FILEPTR *f, char *buf, long bytes));
  139.     long ARGS_ON_STACK (*lseek)    P_((FILEPTR *f, long where, int whence));
  140.     long ARGS_ON_STACK (*ioctl)    P_((FILEPTR *f, int mode, void *buf));
  141.     long ARGS_ON_STACK (*datime)    P_((FILEPTR *f, short *timeptr, int rwflag));
  142.     long ARGS_ON_STACK (*close)    P_((FILEPTR *f, int pid));
  143.     long ARGS_ON_STACK (*select)    P_((FILEPTR *f, long proc, int mode));
  144.     void ARGS_ON_STACK (*unselect)    P_((FILEPTR *f, long proc, int mode));
  145. /* extensions, check dev_descr.drvsize (size of DEVDRV struct) before calling:
  146.  * fast RAW tty byte io  */
  147.     long ARGS_ON_STACK (*writeb)    P_((FILEPTR *f, const char *buf, long bytes));
  148.     long ARGS_ON_STACK (*readb)    P_((FILEPTR *f, char *buf, long bytes));
  149. /* what about: scatter/gather io for DMA devices...
  150.  *    long ARGS_ON_STACK (*writev)    P_((FILEPTR *f, const struct iovec *iov, long cnt));
  151.  *    long ARGS_ON_STACK (*readv)    P_((FILEPTR *f, const struct iovec *iov, long cnt));
  152.  */
  153. } DEVDRV;
  154.  
  155. typedef struct filesys {
  156.     struct    filesys    *next;    /* link to next file system on chain */
  157.     long    fsflags;
  158. #define FS_KNOPARSE    0x01    /* kernel shouldn't do parsing */
  159. #define FS_CASESENSITIVE    0x02    /* file names are case sensitive */
  160. #define FS_NOXBIT    0x04    /* if a file can be read, it can be executed */
  161. #define    FS_LONGPATH    0x08    /* file system understands "size" argument to
  162.                    "getname" */
  163.     long    ARGS_ON_STACK (*root) P_((int drv, fcookie *fc));
  164.     long    ARGS_ON_STACK (*lookup) P_((fcookie *dir, const char *name, fcookie *fc));
  165.     long    ARGS_ON_STACK (*creat) P_((fcookie *dir, const char *name, unsigned mode,
  166.                 int attrib, fcookie *fc));
  167.     DEVDRV * ARGS_ON_STACK (*getdev) P_((fcookie *fc, long *devspecial));
  168.     long    ARGS_ON_STACK (*getxattr) P_((fcookie *file, XATTR *xattr));
  169.     long    ARGS_ON_STACK (*chattr) P_((fcookie *file, int attr));
  170.     long    ARGS_ON_STACK (*chown) P_((fcookie *file, int uid, int gid));
  171.     long    ARGS_ON_STACK (*chmode) P_((fcookie *file, unsigned mode));
  172.     long    ARGS_ON_STACK (*mkdir) P_((fcookie *dir, const char *name, unsigned mode));
  173.     long    ARGS_ON_STACK (*rmdir) P_((fcookie *dir, const char *name));
  174.     long    ARGS_ON_STACK (*remove) P_((fcookie *dir, const char *name));
  175.     long    ARGS_ON_STACK (*getname) P_((fcookie *relto, fcookie *dir,
  176.                 char *pathname, int size));
  177.     long    ARGS_ON_STACK (*rename) P_((fcookie *olddir, char *oldname,
  178.                 fcookie *newdir, const char *newname));
  179.     long    ARGS_ON_STACK (*opendir) P_((DIR *dirh, int tosflag));
  180.     long    ARGS_ON_STACK (*readdir) P_((DIR *dirh, char *name, int namelen, fcookie *fc));
  181.     long    ARGS_ON_STACK (*rewinddir) P_((DIR *dirh));
  182.     long    ARGS_ON_STACK (*closedir) P_((DIR *dirh));
  183.     long    ARGS_ON_STACK (*pathconf) P_((fcookie *dir, int which));
  184.     long    ARGS_ON_STACK (*dfree) P_((fcookie *dir, long *buf));
  185.     long    ARGS_ON_STACK (*writelabel) P_((fcookie *dir, const char *name));
  186.     long    ARGS_ON_STACK (*readlabel) P_((fcookie *dir, char *name, int namelen));
  187.     long    ARGS_ON_STACK (*symlink) P_((fcookie *dir, const char *name, const char *to));
  188.     long    ARGS_ON_STACK (*readlink) P_((fcookie *dir, char *buf, int len));
  189.     long    ARGS_ON_STACK (*hardlink) P_((fcookie *fromdir, const char *fromname,
  190.                 fcookie *todir, const char *toname));
  191.     long    ARGS_ON_STACK (*fscntl) P_((fcookie *dir, const char *name, int cmd, long arg));
  192.     long    ARGS_ON_STACK (*dskchng) P_((int drv));
  193.     long    ARGS_ON_STACK (*release) P_((fcookie *));
  194.     long    ARGS_ON_STACK (*dupcookie) P_((fcookie *new, fcookie *old));
  195. } FILESYS;
  196.  
  197. /*
  198.  * this is the structure passed to loaded file systems to tell them
  199.  * about the kernel
  200.  */
  201.  
  202. struct kerinfo {
  203.     short    maj_version;    /* kernel version number */
  204.     short    min_version;    /* minor kernel version number */
  205.     ushort    default_perm;    /* default file permissions */
  206.     short    reserved1;    /* room for expansion */
  207.  
  208. /* OS functions */
  209.     Func    *bios_tab;    /* pointer to the BIOS entry points */
  210.     Func    *dos_tab;    /* pointer to the GEMDOS entry points */
  211.  
  212. /* media change vector */
  213.     void    ARGS_ON_STACK (*drvchng) P_((unsigned));
  214.  
  215. /* Debugging stuff */
  216.     void    ARGS_ON_STACK (*trace) P_((const char *, ...));
  217.     void    ARGS_ON_STACK (*debug) P_((const char *, ...));
  218.     void    ARGS_ON_STACK (*alert) P_((const char *, ...));
  219.     EXITING void ARGS_ON_STACK (*fatal) P_((const char *, ...)) NORETURN;
  220.  
  221. /* memory allocation functions */
  222.     void *    ARGS_ON_STACK (*kmalloc) P_((long));
  223.     void    ARGS_ON_STACK (*kfree) P_((void *));
  224.     void *    ARGS_ON_STACK (*umalloc) P_((long));
  225.     void    ARGS_ON_STACK (*ufree) P_((void *));
  226.  
  227. /* utility functions for string manipulation */
  228.     int    ARGS_ON_STACK (*strnicmp) P_((const char *, const char *, int));
  229.     int    ARGS_ON_STACK (*stricmp) P_((const char *, const char *));
  230.     char *    ARGS_ON_STACK (*strlwr) P_((char *));
  231.     char *    ARGS_ON_STACK (*strupr) P_((char *));
  232.     int    ARGS_ON_STACK (*sprintf) P_((char *, const char *, ...));
  233.  
  234. /* utility functions for manipulating time */
  235.     void    ARGS_ON_STACK (*millis_time) P_((unsigned long, short *));
  236.     long    ARGS_ON_STACK (*unixtim) P_((unsigned, unsigned));
  237.     long    ARGS_ON_STACK (*dostim) P_((long));
  238.  
  239. /* utility functions for dealing with pauses, or for putting processes
  240.  * to sleep
  241.  */
  242.     void    ARGS_ON_STACK (*nap) P_((unsigned));
  243.     int    ARGS_ON_STACK (*sleep) P_((int que, long cond));
  244.     void    ARGS_ON_STACK (*wake) P_((int que, long cond));
  245.     void    ARGS_ON_STACK (*wakeselect) P_((long param));
  246.  
  247. /* file system utility functions */
  248.     int    ARGS_ON_STACK (*denyshare) P_((FILEPTR *, FILEPTR *));
  249.     LOCK *    ARGS_ON_STACK (*denylock) P_((LOCK *, LOCK *));
  250.  
  251. /* functions for adding/cancelling timeouts */
  252.     struct timeout * ARGS_ON_STACK (*addtimeout) P_((long, void (*)()));
  253.     void    ARGS_ON_STACK (*canceltimeout) P_((struct timeout *));
  254.     struct timeout * ARGS_ON_STACK (*addroottimeout) P_((long, void (*)(), short));
  255.     void    ARGS_ON_STACK (*cancelroottimeout) P_((struct timeout *));
  256.  
  257. /* miscellaneous other things */
  258.     long    ARGS_ON_STACK (*ikill) P_((int, int));
  259.     void    ARGS_ON_STACK (*iwake) P_((int que, long cond, short pid));
  260.  
  261. /* reserved for future use */
  262.     long    res2[3];
  263. };
  264.  
  265. /* flags for open() modes */
  266. #define O_RWMODE      0x03    /* isolates file read/write mode */
  267. #    define O_RDONLY    0x00
  268. #    define O_WRONLY    0x01
  269. #    define O_RDWR    0x02
  270. #    define O_EXEC    0x03    /* execute file; used by kernel only */
  271.  
  272. /* 0x04 is for future expansion */
  273. #define O_APPEND    0x08    /* all writes go to end of file */
  274.  
  275. #define O_SHMODE    0x70    /* isolates file sharing mode */
  276. #    define O_COMPAT    0x00    /* compatibility mode */
  277. #    define O_DENYRW    0x10    /* deny both read and write access */
  278. #    define O_DENYW    0x20    /* deny write access to others */
  279. #    define O_DENYR    0x30    /* deny read access to others */
  280. #    define O_DENYNONE 0x40    /* don't deny any access to others */
  281.  
  282. #define O_NOINHERIT    0x80    /* private file (not passed to child) */
  283.  
  284. #define O_NDELAY    0x100    /* don't block for i/o on this file */
  285. #define O_CREAT        0x200    /* create file if it doesn't exist */
  286. #define O_TRUNC        0x400    /* truncate file to 0 bytes if it does exist */
  287. #define O_EXCL        0x800    /* fail open if file exists */
  288.  
  289. #define O_USER        0x0fff    /* isolates user-settable flag bits */
  290.  
  291. #define O_GLOBAL    0x1000    /* for opening a global file */
  292.  
  293. /* kernel mode bits -- the user can't set these! */
  294. #define O_TTY        0x2000
  295. #define O_HEAD        0x4000
  296. #define O_LOCK        0x8000
  297.  
  298. /* GEMDOS file attributes */
  299.  
  300. /* macros to be applied to FILEPTRS to determine their type */
  301. #define is_terminal(f) (f->flags & O_TTY)
  302.  
  303. /* lseek() origins */
  304. #define    SEEK_SET    0        /* from beginning of file */
  305. #define    SEEK_CUR    1        /* from current location */
  306. #define    SEEK_END    2        /* from end of file */
  307.  
  308. /* The requests for Dpathconf() */
  309. #define DP_IOPEN    0    /* internal limit on # of open files */
  310. #define DP_MAXLINKS    1    /* max number of hard links to a file */
  311. #define DP_PATHMAX    2    /* max path name length */
  312. #define DP_NAMEMAX    3    /* max length of an individual file name */
  313. #define DP_ATOMIC    4    /* # of bytes that can be written atomically */
  314. #define DP_TRUNC    5    /* file name truncation behavior */
  315. #    define    DP_NOTRUNC    0    /* long filenames give an error */
  316. #    define    DP_AUTOTRUNC    1    /* long filenames truncated */
  317. #    define    DP_DOSTRUNC    2    /* DOS truncation rules in effect */
  318. #define DP_CASE        6
  319. #    define    DP_CASESENS    0    /* case sensitive */
  320. #    define    DP_CASECONV    1    /* case always converted */
  321. #    define    DP_CASEINSENS    2    /* case insensitive, preserved */
  322. #define DP_MODEATTR        7
  323. #    define    DP_ATTRBITS    0x000000ffL    /* mask for valid TOS attribs */
  324. #    define    DP_MODEBITS    0x000fff00L    /* mask for valid Unix file modes */
  325. #    define    DP_FILETYPS    0xfff00000L    /* mask for valid file types */
  326. #    define    DP_FT_DIR    0x00100000L    /* directories (always if . is there) */
  327. #    define    DP_FT_CHR    0x00200000L    /* character special files */
  328. #    define    DP_FT_BLK    0x00400000L    /* block special files, currently unused */
  329. #    define    DP_FT_REG    0x00800000L    /* regular files */
  330. #    define    DP_FT_LNK    0x01000000L    /* symbolic links */
  331. #    define    DP_FT_SOCK    0x02000000L    /* sockets, currently unused */
  332. #    define    DP_FT_FIFO    0x04000000L    /* pipes */
  333. #    define    DP_FT_MEM    0x08000000L    /* shared memory or proc files */
  334. #define DP_XATTRFIELDS    8
  335. #    define    DP_INDEX    0x0001
  336. #    define    DP_DEV        0x0002
  337. #    define    DP_RDEV        0x0004
  338. #    define    DP_NLINK    0x0008
  339. #    define    DP_UID        0x0010
  340. #    define    DP_GID        0x0020
  341. #    define    DP_BLKSIZE    0x0040
  342. #    define    DP_SIZE        0x0080
  343. #    define    DP_NBLOCKS    0x0100
  344. #    define    DP_ATIME    0x0200
  345. #    define    DP_CTIME    0x0400
  346. #    define    DP_MTIME    0x0800
  347. #define DP_MAXREQ    8    /* highest legal request */
  348.  
  349. /* Dpathconf and Sysconf return this when a value is not limited
  350.    (or is limited only by available memory) */
  351.  
  352. #define UNLIMITED    0x7fffffffL
  353.  
  354. /* various character constants and defines for TTY's */
  355. #define MiNTEOF 0x0000ff1a    /* 1a == ^Z */
  356.  
  357. /* defines for tty_read */
  358. #define RAW    0
  359. #define COOKED    0x1
  360. #define NOECHO    0
  361. #define ECHO    0x2
  362. #define ESCSEQ    0x04        /* cursor keys, etc. get escape sequences */
  363.  
  364. /* constants for Fcntl calls */
  365. #define F_DUPFD        0        /* handled by kernel */
  366. #define F_GETFD        1        /* handled by kernel */
  367. #define F_SETFD        2        /* handled by kernel */
  368. #    define FD_CLOEXEC    1    /* close on exec flag */
  369.  
  370. #define F_GETFL        3        /* handled by kernel */
  371. #define F_SETFL        4        /* handled by kernel */
  372. #define F_GETLK        5
  373. #define F_SETLK        6
  374. #define F_SETLKW    7
  375.  
  376. /* more constants for various Fcntl's */
  377. #define FSTAT        (('F'<< 8) | 0)        /* handled by kernel */
  378. #define FIONREAD    (('F'<< 8) | 1)
  379. #define FIONWRITE    (('F'<< 8) | 2)
  380. #define FIOEXCEPT    (('F'<< 8) | 5)
  381. #define TIOCGETP    (('T'<< 8) | 0)
  382. #define TIOCSETN    (('T'<< 8) | 1)
  383. #define TIOCGETC    (('T'<< 8) | 2)
  384. #define TIOCSETC    (('T'<< 8) | 3)
  385. #define TIOCGLTC    (('T'<< 8) | 4)
  386. #define TIOCSLTC    (('T'<< 8) | 5)
  387. #define TIOCGPGRP    (('T'<< 8) | 6)
  388. #define TIOCSPGRP    (('T'<< 8) | 7)
  389. #define TIOCFLUSH    (('T'<< 8) | 8)
  390. #define TIOCSTOP    (('T'<< 8) | 9)
  391. #define TIOCSTART    (('T'<< 8) | 10)
  392. #define TIOCGWINSZ    (('T'<< 8) | 11)
  393. #define TIOCSWINSZ    (('T'<< 8) | 12)
  394. #define TIOCGXKEY    (('T'<< 8) | 13)
  395. #define TIOCSXKEY    (('T'<< 8) | 14)
  396. #define TIOCIBAUD    (('T'<< 8) | 18)
  397. #define TIOCOBAUD    (('T'<< 8) | 19)
  398. #define TIOCCBRK    (('T'<< 8) | 20)
  399. #define TIOCSBRK    (('T'<< 8) | 21)
  400. #define TIOCGFLAGS    (('T'<< 8) | 22)
  401. #define TIOCSFLAGS    (('T'<< 8) | 23)
  402. #define TIOCOUTQ    (('T'<< 8) | 24)
  403. #define TIOCSETP    (('T'<< 8) | 25)
  404. #define TIOCHPCL    (('T'<< 8) | 26)
  405. #define TIOCCAR        (('T'<< 8) | 27)
  406. #define TIOCNCAR    (('T'<< 8) | 28)
  407. #define TIOCWONLINE    (('T'<< 8) | 29)
  408. #define TIOCSFLAGSB    (('T'<< 8) | 30)
  409. #define TIOCGSTATE    (('T'<< 8) | 31)
  410. #define TIOCSSTATEB    (('T'<< 8) | 32)
  411. #define TIOCGVMIN    (('T'<< 8) | 33)
  412. #define TIOCSVMIN    (('T'<< 8) | 34)
  413.  
  414. /* cursor control Fcntls:
  415.  * NOTE THAT THESE MUST BE TOGETHER
  416.  */
  417. #define TCURSOFF    (('c'<< 8) | 0)
  418. #define TCURSON        (('c'<< 8) | 1)
  419. #define TCURSBLINK    (('c'<< 8) | 2)
  420. #define TCURSSTEADY    (('c'<< 8) | 3)
  421. #define TCURSSRATE    (('c'<< 8) | 4)
  422. #define TCURSGRATE    (('c'<< 8) | 5)
  423.  
  424. /* process stuff */
  425. #define PPROCADDR    (('P'<< 8) | 1)
  426. #define PBASEADDR    (('P'<< 8) | 2)
  427. #define PCTXTSIZE    (('P'<< 8) | 3)
  428. #define PSETFLAGS    (('P'<< 8) | 4)
  429. #define PGETFLAGS    (('P'<< 8) | 5)
  430. #define PTRACESFLAGS    (('P'<< 8) | 6)
  431. #define PTRACEGFLAGS    (('P'<< 8) | 7)
  432. #    define    P_ENABLE    (1 << 0)    /* enable tracing */
  433. #ifdef NOTYETDEFINED
  434. #    define    P_DOS        (1 << 1)    /* trace DOS calls - unimplemented */
  435. #    define    P_BIOS        (1 << 2)    /* trace BIOS calls - unimplemented */
  436. #    define    P_XBIOS        (1 << 3)    /* trace XBIOS calls - unimplemented */
  437. #endif
  438.  
  439. #define PTRACEGO    (('P'<< 8) | 8)    /* these 4 must be together */
  440. #define PTRACEFLOW    (('P'<< 8) | 9)
  441. #define PTRACESTEP    (('P'<< 8) | 10)
  442. #define PTRACE11    (('P'<< 8) | 11)
  443. #define PLOADINFO    (('P'<< 8) | 12)
  444. #define    PFSTAT        (('P'<< 8) | 13)
  445.  
  446. struct ploadinfo {
  447.     /* passed */
  448.     short fnamelen;
  449.     /* returned */
  450.     char *cmdlin, *fname;
  451. };
  452.  
  453.  
  454. #define SHMGETBLK    (('M'<< 8) | 0)
  455. #define SHMSETBLK    (('M'<< 8) | 1)
  456.  
  457. /* terminal control constants (tty.sg_flags) */
  458. #define T_CRMOD        0x0001
  459. #define T_CBREAK    0x0002
  460. #define T_ECHO        0x0004
  461. /* #define T_XTABS    0x0008  unimplemented*/
  462. #define T_RAW        0x0010
  463. /* #define T_LCASE    0x0020  unimplemented */
  464.  
  465. #define T_NOFLSH    0x0040        /* don't flush buffer when signals
  466.                        are received */
  467. #define T_TOS        0x0080
  468. #define T_TOSTOP    0x0100
  469. #define T_XKEY        0x0200        /* Fread returns escape sequences for
  470.                        cursor keys, etc. */
  471. #define T_ECHOCTL    0x0400        /* echo ctl chars as ^x */
  472. /* 0x0800 still available */
  473.  
  474. #define T_TANDEM    0x1000
  475. #define T_RTSCTS    0x2000
  476. #define T_EVENP        0x4000        /* EVENP and ODDP are mutually exclusive */
  477. #define T_ODDP        0x8000
  478.  
  479. #define TF_FLAGS    0xF000
  480.  
  481. /* some flags for TIOC[GS]FLAGS */
  482. #define TF_CAR        0x800        /* nonlocal mode, require carrier */
  483. #define TF_NLOCAL    TF_CAR
  484.  
  485. #define TF_BRKINT    0x80        /* allow breaks interrupt (like ^C) */
  486.  
  487. #define TF_STOPBITS    0x0003
  488. #define TF_1STOP    0x0001
  489. #define TF_15STOP    0x0002
  490. #define    TF_2STOP    0x0003
  491.  
  492. #define TF_CHARBITS    0x000C
  493. #define TF_8BIT        0
  494. #define TF_7BIT        0x4
  495. #define TF_6BIT        0x8
  496. #define TF_5BIT        0xC
  497.  
  498. /* the following are terminal status flags (tty.state) */
  499. /* (the low byte of tty.state indicates a part of an escape sequence still
  500.  * hasn't been read by Fread, and is an index into that escape sequence)
  501.  */
  502. #define TS_ESC        0x00ff
  503. #define TS_BLIND    0x800        /* tty is `blind' i.e. has no carrier
  504.                        (cleared in local mode) */
  505. #define TS_HOLD        0x1000        /* hold (e.g. ^S/^Q) */
  506. #define TS_HPCL        0x4000        /* hang up on close */
  507. #define TS_COOKED    0x8000        /* interpret control chars */
  508.  
  509. /* structures for terminals */
  510. struct tchars {
  511.     char t_intrc;
  512.     char t_quitc;
  513.     char t_startc;
  514.     char t_stopc;
  515.     char t_eofc;
  516.     char t_brkc;
  517. };
  518.  
  519. struct ltchars {
  520.     char t_suspc;
  521.     char t_dsuspc;
  522.     char t_rprntc;
  523.     char t_flushc;
  524.     char t_werasc;
  525.     char t_lnextc;
  526. };
  527.  
  528. struct sgttyb {
  529.     char sg_ispeed;
  530.     char sg_ospeed;
  531.     char sg_erase;
  532.     char sg_kill;
  533.     ushort sg_flags;
  534. };
  535.  
  536. struct winsize {
  537.     short    ws_row;
  538.     short    ws_col;
  539.     short    ws_xpixel;
  540.     short    ws_ypixel;
  541. };
  542.  
  543. struct xkey {
  544.     short    xk_num;
  545.     char    xk_def[8];
  546. };
  547.  
  548. struct tty {
  549.     short        pgrp;        /* process group of terminal */
  550.     short        state;        /* terminal status, e.g. stopped */
  551.     short        use_cnt;    /* number of times terminal is open */
  552.     short        aux_cnt;    /* number of times terminal is open as
  553.                        /dev/aux */
  554.     struct sgttyb     sg;
  555.     struct tchars     tc;
  556.     struct ltchars     ltc;
  557.     struct winsize    wsiz;
  558.     long        rsel;        /* selecting process for read */
  559.     long        wsel;        /* selecting process for write */
  560.     char        *xkey;        /* extended keyboard table */
  561.     long        hup_ospeed;    /* saved ospeed while hanging up */
  562.     unsigned short    vmin, vtime;    /* min chars, timeout for RAW reads */
  563.     long        resrvd[1];    /* for future expansion */
  564. };
  565.  
  566. struct bios_tty {
  567.     IOREC_T        *irec;        /* From XBIOS ... */
  568.     long        *rsel;        /* pointer to field in tty struct */
  569.     IOREC_T        *orec;        /* Same, for output... */
  570.     long        *wsel;
  571.     long        ispeed, ospeed;    /* last speeds set */
  572.     long        *baudmap, maxbaud; /* Rsconf baud word <-> bps table */
  573.     short        *baudx;
  574.     struct tty    *tty;
  575.     long        bticks;        /* when to take a break for real */
  576.     long        vticks;        /* ..check read buf next (vmin/speed) */
  577.     char        clocal, brkint;    /* flags: local mode, break == ^C */
  578.     short        tosfd;        /* if != EUNDEV: fd to pass Fcntl()s */
  579.     short        bdev, unused1;
  580. };
  581.  
  582. /* Dcntl constants and types */
  583. #define DEV_NEWTTY    0xde00
  584. #define DEV_NEWBIOS    0xde01
  585. #define DEV_INSTALL    0xde02
  586.  
  587. struct dev_descr {
  588.     DEVDRV    *driver;
  589.     short    dinfo;
  590.     short    flags;
  591.     struct tty *tty;
  592.     long    drvsize;        /* size of DEVDRV struct */
  593.     long    reserved[3];
  594. };
  595.  
  596.  
  597. #define FS_INSTALL    0xf001  /* let the kernel know about the file system */
  598. #define FS_MOUNT      0xf002  /* make a new directory for a file system */
  599. #define FS_UNMOUNT    0xf003  /* remove a directory for a file system */
  600. #define FS_UNINSTALL  0xf004  /* remove a file system from the list */
  601.  
  602.  
  603. struct fs_descr
  604. {
  605.     FILESYS *file_system;
  606.     short dev_no;    /* this is filled in by MiNT if arg == FS_MOUNT*/
  607.     long flags;
  608.     long reserved[4];
  609. };
  610.  
  611.  
  612. /* number of BIOS drives */
  613. #define NUM_DRIVES 32
  614.  
  615. #define BIOSDRV (NUM_DRIVES)
  616. #define PIPEDRV (NUM_DRIVES+1)
  617. #define PROCDRV (NUM_DRIVES+2)
  618. #define SHMDRV    (NUM_DRIVES+3)
  619.  
  620. #define UNI_NUM_DRVS (NUM_DRIVES+4)
  621. #define UNIDRV    ('U'-'A')
  622.  
  623. #define PSEUDODRVS ((1L<<UNIDRV))
  624.  
  625. /* various fields for the "rdev" device numbers */
  626. #define BIOS_DRIVE_RDEV     0x0000
  627. #define BIOS_RDEV    0x0100
  628. #define FAKE_RDEV    0x0200
  629. #define PIPE_RDEV    0x7e00
  630. #define UNK_RDEV    0x7f00
  631. #define PROC_RDEV_BASE    0xa000
  632.  
  633. #ifndef GENMAGIC
  634. /* external variables */
  635.  
  636. extern FILESYS *drives[NUM_DRIVES];
  637. extern struct tty default_tty;
  638. #define follow_links ((char *)-1L)
  639. #endif
  640.  
  641. /* internal bios file structure */
  642.  
  643. #define    BNAME_MAX    13
  644.  
  645. struct bios_file {
  646.     char     name[BNAME_MAX+1];    /* device name */
  647.     DEVDRV *device;            /* device driver for device */
  648.     short    private;        /* extra info for device driver */
  649.     ushort    flags;            /* flags for device open */
  650.     struct tty *tty;        /* tty structure (if appropriate) */
  651.     struct bios_file *next;
  652.     short    lockpid;        /* owner of the lock */
  653.     XATTR    xattr;            /* guess what... */
  654.     long    drvsize;        /* size of DEVDRV struct */
  655. };
  656.  
  657. #endif /* _filesys_h */
  658.